using System;
using Castle.ActiveRecord;
using System.Collections.Generic;

namespace IronMis2.Models
{
    [ActiveRecord("exchange")]
    public class Exchange:ActiveRecordBase<Exchange>
    {
        private Guid id;
        private string exchangeId;
        private DateTime? exDate;
        private Storehouse exSrc;
        private Storehouse exAim;
        private Employee employee;
        private IList<CommodityRecord> items;

        [PrimaryKey(PrimaryKeyType.GuidComb,Column = "id")]
        public Guid Id
        {
            set { id = value; }
            get { return id; }
        }

        [Property(Column = "exchange_id",SqlType = "char",Length = 10)]
        public string ExchangeId
        {
            set { exchangeId = value; }
            get { return exchangeId; }
        }

        [Property(Column = "ex_date",SqlType = "datetime",Length = 8)]
        public DateTime? ExDate
        {
            set { exDate = value; }
            get { return exDate; }
        }

        [BelongsTo(Column = "ex_src",ForeignKey = "id",Insert = true,Update = true,Fetch = FetchEnum.Select)]
        public Storehouse ExSrc
        {
            set { exSrc = value; }
            get { return exSrc; }
        }

        [BelongsTo(Column = "ex_aim",ForeignKey = "id",Insert = true,Update = true,Fetch = FetchEnum.Select)]
        public Storehouse ExAim
        {
            set { exAim = value; }
            get { return exAim; }
        }

        [BelongsTo(Column = "s_number",ForeignKey = "id",Insert = true,Update = true,Fetch = FetchEnum.Select)]
        public Employee Employee
        {
            set { employee = value; }
            get { return employee; }
        }

        [HasMany(Lazy = true, Inverse = true, Cascade = ManyRelationCascadeEnum.All)]
        public IList<CommodityRecord> Items
        {
            set { items = value; }
            get { return items; }
        }
    }
}
